package org.example.Swing.studentView;

import java.awt.Color;
import java.awt.Font;
import java.util.Vector;

import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumn;

public class MainViewTable extends JTable{
	public MainViewTable() {
		// 设置表头
		JTableHeader tableHeader=getTableHeader();
		tableHeader.setFont(new Font(null, Font.BOLD, 16));
		tableHeader.setForeground(Color.RED);
		//设置表格体
		setFont(new Font(null, Font.PLAIN, 14));
		setForeground(Color.black);
		setGridColor(Color.black);
		setRowHeight(30);
		//设置多行选择
		getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
	}
	public void renderRule(){
		// 设置表格列的渲染方式
		Vector<String> colums= MainViewTableModel.getColums();
		MainViewCellRender render=new MainViewCellRender();
		for (int i = 0; i < colums.size(); i++) {
			TableColumn column = getColumn(colums.get(i));
			column.setCellRenderer(render);
			if (0 == i){
				column.setPreferredWidth(50);
				column.setMaxWidth(50);
				column.setResizable(false);
			}
		}
	}
}
